uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Determines if a rule belongs to a nested (local) transformer rather than the main (root) transformer.
The IsChildRule property is a boolean flag that indicates whether a rule is part of a nested parsing context. It returns true if the rule was defined on a 'local' transformer—one obtained from another rule's LocalTransformer property. This is a key introspection tool for understanding the scope and hierarchy of your transformation logic.
Transformer object. For these rules, IsChildRule returns false.Transformer object returned by another rule's @LocalTransformer() property. For these rules, IsChildRule returns true.This property allows you to distinguish between top-level patterns and sub-patterns that only execute within the scope of a specific parent match. This is crucial for debugging complex, nested parsing logic or for writing generic functions that behave differently based on a rule's scope.
vs. Regular Expressions: Standard regex engines have a 'flat' model; there is no concept of a rule hierarchy. Achieving nested parsing requires complex and often fragile recursive patterns or lookarounds. uCalc's LocalTransformer creates a true hierarchical parsing model, and IsChildRule is the built-in tool to inspect this structure. It provides a level of architectural clarity that is absent in traditional regex.
vs. Parser Generators (ANTLR, etc.): While parser generators define grammars with clear hierarchical rules (e.g., a statement contains an expression), this hierarchy is static and defined in a grammar file. uCalc's model is entirely dynamic and programmatic. You can build and query these parent-child relationships at runtime, and IsChildRule is the primary way to do so.
ID: 937
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
var rootRule = t.Pattern("root");
var localTransformer = rootRule.LocalTransformer;
var childRule = localTransformer.Pattern("child");
Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}");
Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}");
Is 'rootRule' a child? False
Is 'childRule' a child? True using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); var rootRule = t.Pattern("root"); var localTransformer = rootRule.LocalTransformer; var childRule = localTransformer.Pattern("child"); Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}"); Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
auto rootRule = t.Pattern("root");
auto localTransformer = rootRule.LocalTransformer();
auto childRule = localTransformer.Pattern("child");
cout << "Is 'rootRule' a child? " << tf(rootRule.IsChildRule()) << endl;
cout << "Is 'childRule' a child? " << tf(childRule.IsChildRule()) << endl;
}
Is 'rootRule' a child? False
Is 'childRule' a child? True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc::Transformer t; auto rootRule = t.Pattern("root"); auto localTransformer = rootRule.LocalTransformer(); auto childRule = localTransformer.Pattern("child"); cout << "Is 'rootRule' a child? " << tf(rootRule.IsChildRule()) << endl; cout << "Is 'childRule' a child? " << tf(childRule.IsChildRule()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim rootRule = t.Pattern("root")
Dim localTransformer = rootRule.LocalTransformer
Dim childRule = localTransformer.Pattern("child")
Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}")
Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}")
End Sub
End Module
Is 'rootRule' a child? False
Is 'childRule' a child? True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim rootRule = t.Pattern("root") Dim localTransformer = rootRule.LocalTransformer Dim childRule = localTransformer.Pattern("child") Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}") Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}") End Sub End Module
ID: 938
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
var grandParentRule = t.Pattern("grandparent");
// Create a child
var parentTransformer = grandParentRule.LocalTransformer;
var parentRule = parentTransformer.Pattern("parent");
// Create a grandchild
var childTransformer = parentRule.LocalTransformer;
var childRule = childTransformer.Pattern("child");
Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}");
Console.WriteLine($"Parent is child: {parentRule.IsChildRule}");
Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}");
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: True using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); var grandParentRule = t.Pattern("grandparent"); // Create a child var parentTransformer = grandParentRule.LocalTransformer; var parentRule = parentTransformer.Pattern("parent"); // Create a grandchild var childTransformer = parentRule.LocalTransformer; var childRule = childTransformer.Pattern("child"); Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}"); Console.WriteLine($"Parent is child: {parentRule.IsChildRule}"); Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
auto grandParentRule = t.Pattern("grandparent");
// Create a child
auto parentTransformer = grandParentRule.LocalTransformer();
auto parentRule = parentTransformer.Pattern("parent");
// Create a grandchild
auto childTransformer = parentRule.LocalTransformer();
auto childRule = childTransformer.Pattern("child");
cout << "Grandparent is child: " << tf(grandParentRule.IsChildRule()) << endl;
cout << "Parent is child: " << tf(parentRule.IsChildRule()) << endl;
cout << "Child (grandchild) is child: " << tf(childRule.IsChildRule()) << endl;
}
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc::Transformer t; auto grandParentRule = t.Pattern("grandparent"); // Create a child auto parentTransformer = grandParentRule.LocalTransformer(); auto parentRule = parentTransformer.Pattern("parent"); // Create a grandchild auto childTransformer = parentRule.LocalTransformer(); auto childRule = childTransformer.Pattern("child"); cout << "Grandparent is child: " << tf(grandParentRule.IsChildRule()) << endl; cout << "Parent is child: " << tf(parentRule.IsChildRule()) << endl; cout << "Child (grandchild) is child: " << tf(childRule.IsChildRule()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim grandParentRule = t.Pattern("grandparent")
'// Create a child
Dim parentTransformer = grandParentRule.LocalTransformer
Dim parentRule = parentTransformer.Pattern("parent")
'// Create a grandchild
Dim childTransformer = parentRule.LocalTransformer
Dim childRule = childTransformer.Pattern("child")
Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}")
Console.WriteLine($"Parent is child: {parentRule.IsChildRule}")
Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}")
End Sub
End Module
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim grandParentRule = t.Pattern("grandparent") '// Create a child Dim parentTransformer = grandParentRule.LocalTransformer Dim parentRule = parentTransformer.Pattern("parent") '// Create a grandchild Dim childTransformer = parentRule.LocalTransformer Dim childRule = childTransformer.Pattern("child") Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}") Console.WriteLine($"Parent is child: {parentRule.IsChildRule}") Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}") End Sub End Module
ID: 126
using uCalcSoftware;
var uc = new uCalc();
// Note the change in section/div/h2
var t = uc.NewTransformer();
var rule = t.Pattern("{body} ").SetStatementSensitive(false);
var section = rule.LocalTransformer;
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
");
section.SkipOver("&{entity};");
var ch = section.FromTo("{text}
", "SELECTED: {text}
");
Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}");
Console.WriteLine($"rule is a child rule: {rule.IsChildRule}");
Console.WriteLine($"ch is a child rule: {ch.IsChildRule}");
var HtmlText =
"""
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
""";
t.Text = HtmlText;
t.Transform();
Console.WriteLine(t.Text);
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> using uCalcSoftware; var uc = new uCalc(); // Note the change in section/div/h2 var t = uc.NewTransformer(); var rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false); var section = rule.LocalTransformer; section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>"); section.SkipOver("&{entity};"); var ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>"); Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}"); Console.WriteLine($"rule is a child rule: {rule.IsChildRule}"); Console.WriteLine($"ch is a child rule: {ch.IsChildRule}"); var HtmlText = """ <div class="article" data-id="1"> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class="article" data-id="2"> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class="article" data-id="3"> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class="article" data-id="4"> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> """; t.Text = HtmlText; t.Transform(); Console.WriteLine(t.Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
// Note the change in section/div/h2
auto t = uc.NewTransformer();
auto rule = t.Pattern("{body} ").SetStatementSensitive(false);
auto section = rule.LocalTransformer();
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
");
section.SkipOver("&{entity};");
auto ch = section.FromTo("{text}
", "SELECTED: {text}
");
cout << "Has a local transformer: " << tf(rule.HasLocalTransformer()) << endl;
cout << "rule is a child rule: " << tf(rule.IsChildRule()) << endl;
cout << "ch is a child rule: " << tf(ch.IsChildRule()) << endl;
auto HtmlText =
R"(
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
)";
t.Text(HtmlText);
t.Transform();
cout << t.Text() << endl;
}
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; // Note the change in section/div/h2 auto t = uc.NewTransformer(); auto rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false); auto section = rule.LocalTransformer(); section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>"); section.SkipOver("&{entity};"); auto ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>"); cout << "Has a local transformer: " << tf(rule.HasLocalTransformer()) << endl; cout << "rule is a child rule: " << tf(rule.IsChildRule()) << endl; cout << "ch is a child rule: " << tf(ch.IsChildRule()) << endl; auto HtmlText = R"( <div class="article" data-id="1"> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class="article" data-id="2"> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class="article" data-id="3"> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class="article" data-id="4"> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> )"; t.Text(HtmlText); t.Transform(); cout << t.Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Note the change in section/div/h2
Dim t = uc.NewTransformer()
Dim rule = t.Pattern("{body} ").SetStatementSensitive(false)
Dim section = rule.LocalTransformer
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
")
section.SkipOver("&{entity};")
Dim ch = section.FromTo("{text}
", "SELECTED: {text}
")
Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}")
Console.WriteLine($"rule is a child rule: {rule.IsChildRule}")
Console.WriteLine($"ch is a child rule: {ch.IsChildRule}")
Dim HtmlText =
"
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
"
t.Text = HtmlText
t.Transform()
Console.WriteLine(t.Text)
End Sub
End Module
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Note the change in section/div/h2 Dim t = uc.NewTransformer() Dim rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false) Dim section = rule.LocalTransformer section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>") section.SkipOver("&{entity};") Dim ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>") Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}") Console.WriteLine($"rule is a child rule: {rule.IsChildRule}") Console.WriteLine($"ch is a child rule: {ch.IsChildRule}") Dim HtmlText = " <div class=""article"" data-id=""1""> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class=""article"" data-id=""2""> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class=""article"" data-id=""3""> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class=""article"" data-id=""4""> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> " t.Text = HtmlText t.Transform() Console.WriteLine(t.Text) End Sub End Module